package com.by.redis.support;

import cn.hutool.extra.spring.SpringUtil;
import com.by.redis.enums.ByRedisUtilityEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class ByRedisSupport {

    public StringRedisTemplate getStringRedisTemplate(ByRedisUtilityEnum utilityEnum) {
        return SpringUtil.getBean(utilityEnum.getStrRedisTemplateName(), StringRedisTemplate.class);
    }

    public RedisTemplate<String, Object> getJsonRedisTemplate(ByRedisUtilityEnum utilityEnum) {
        return SpringUtil.getBean(utilityEnum.getJsonRedisTemplateName(), RedisTemplate.class);
    }

}
